$('#change').on('click',function () {
    $('#change').hide();
    $('#save').show();
    var tbody=window.document.getElementById("tbody-result");
    var ss=new Object();
    ss.name=tbody.rows[0].cells[0].innerHTML;
    ss.phone=tbody.rows[0].cells[1].innerHTML;
    ss.sex=tbody.rows[0].cells[3].innerHTML;
    ss.userid=tbody.rows[0].cells[2].innerHTML;
    tbody.rows[0].cells[0].innerHTML="<input type='=text'id='name' value='"+ss.name+"'/>";
            tbody.rows[0].cells[1].innerHTML="<input type='=text'id='phone' value='"+ss.phone+"'/>";
            tbody.rows[0].cells[3].innerHTML="<input type='=text'id='sex' value='"+ss.sex+"'/>";
            tbody.rows[0].cells[2].innerHTML="<input type='=text' id='userid' value='"+ss.userid+"'/>";
    // $.ajax({
    //     type: 'GET',
    //     dataType: 'json',
    //     url: contextPath + "admin/update",
    //     success:function () {
    //         tbody.rows[0].cells[0].innerHTML="<input type='=text' value='"+ss.name+"'/>";
    //         tbody.rows[0].cells[1].innerHTML="<input type='=text' value='"+ss.phone+"'/>";
    //         tbody.rows[0].cells[3].innerHTML="<input type='=text' value='"+ss.name+"'/>";
    //         tbody.rows[0].cells[2].innerHTML="<input type='=text' value='"+ss.name+"'/>";
    //     },
    //     error:function () {
    //         alert("修改失败")
    //     }
    // })
});
$('#save').on('click',function () {
    var tbody=window.document.getElementById("tbody-result");
    var ss=new Object();
    ss.name=document.getElementById("name").value;
    ss.phone=document.getElementById("phone").value;
    ss.sex=document.getElementById("sex").value;
    ss.userid=document.getElementById("userid").value;
    $.ajax({
            type:'PUT',
            dataType:'json',
            contentType: "application/json; charset=utf-8",
            url: contextPath + "admin/update",
            data:JSON.stringify(ss),
            success:function (data) {
                $('#change').show();
                tbody.rows[0].cells[0].innerHTML=ss.name;
                tbody.rows[0].cells[1].innerHTML=ss.phone;
                tbody.rows[0].cells[3].innerHTML=ss.sex;
                tbody.rows[0].cells[2].innerHTML=ss.userid;
                $('#save').hide();
                alert(data.message)
            },
            error:function () {
                alert("修改失败")
            }
        })
});